using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Web;using CefSharp;using CefSharp.WinForms;using YjiaLife.Utils;using System.Configuration;namespace YjiaLife{ public partial class Form1 : Form { //BardCodeHooK BarCode = new BardCodeHooK(); private ScanerHook listener = new ScanerHook(); //string value = ""; //value为扫码枪获取的内容,以Enter结尾 //private delegate void ShowInfoDelegate(BardCodeHooK.BarCodes barCode); public Form1() { InitializeComponent(); } public ChromiumWebBrowser browser; [Obsolete] public void InitBrowser() { InitializeComponent(); this.MaximizeBox = false; this.MinimizeBox = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; string url = ConfigurationSettings.AppSettings["url"].ToString(); int wide = Convert.ToInt32(ConfigurationSettings.AppSettings["wide"].ToString()); int high = Convert.ToInt32(ConfigurationSettings.AppSettings["high"].ToString()); //string url = "https://m.1jingxi.com/surpriseplus/jump"; ChromiumWebBrowser webview = new ChromiumWebBrowser(url); webview.Dock = DockStyle.Fill; webview.Width = wide; webview.Height = high; webview.ConsoleMessage = OnConsoleMessage; webview.StatusMessage = OnBrowserStatusMessage; CefSharpSettings.LegacyJavascriptBindingEnabled = true; webview.JavascriptObjectRepository.Register("JsObject", new Class1(), false, BindingOptions.DefaultBinder); webview.KeyboardHandler = new CEFKeyBoardHander(); this.Controls.Add(webview); //BarCode.BarCodeEvent = new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent); listener.ScanerEvent = Listener_ScanerEvent; } /// <summary>浏览器状态记录</summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnBrowserStatusMessage(object sender, StatusMessageEventArgs args) { //loggerAlp.Info(args.Value); } /// <summary>浏览器错误信息记录</summary> /// <param name="o"></param> /// <param name="args"></param> private void OnConsoleMessage(object o, ConsoleMessageEventArgs args) { //loggerAlp.Info(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message)); } [Obsolete] private void Form1_Load(object sender, EventArgs e) { InitBrowser(); } //private void ShowInfo(BardCodeHooK.BarCodes barCode) //{ // if (this.InvokeRequired) // { // this.BeginInvoke(new ShowInfoDelegate(ShowInfo), new object[] { barCode }); // } // else // { // if (barCode.KeyName.Equals("Enter")) // { // //hook_KeyDown(value); // value = ""; // } // else // { // value = barCode.Chr.ToString();6972294972179 // } // } // MessageBox.Show(value); //} //void BarCode_BarCodeEvent(BardCodeHooK.BarCodes barCode) //{ // ShowInfo(barCode); //} private void Listener_ScanerEvent(ScanerHook.ScanerCodes codes) { MessageBox.Show(codes.Result); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { listener.Stop(); } //使用例1(LPT打印): // printLPT.PrintESC(0); //打印前退纸 // printLPT.PrintDataSet(dsPrint); // printLPT.PrintESC(1); //打印后进纸 }}
评论